<link rel="shortcut  icon" type="image/x-icon" href="img/icon/favicon.ico" media="screen">
<!-- 框架样式 -->
<link type="text/css" rel="stylesheet" href="${static}/fonts/font-icons.min.css">
<!--<link type="text/css" rel="stylesheet" href="${static}/css/bootstrap.min.css">-->
<link type="text/css" rel="stylesheet" href="${static}/css/bootstrap.css">
<link type="text/css" rel="stylesheet" href="${static}/plugin/layui/css/layui.css">
<link type="text/css" rel="stylesheet" href="${static}/plugin/datatable/media/css/dataTables.bootstrap.min.css">
<link type="text/css" rel="stylesheet" href="${static}/plugin/bootstrap-select/css/bootstrap-select.min.css?r=0.020456797551074324">
<link rel="stylesheet" type="text/css" href="${static}/plugin/bootstrap-datetimepicker-master/css/bootstrap-datetimepicker.css">
<link type="text/css" rel="stylesheet" href="${static}/plugin/radioCheckBox/src/pretty.min.css">
<link type="text/css" rel="stylesheet" href="${static}/plugin/materialdesignicons/css/materialdesignicons.min.css">
<link async rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/material-design-iconic-font/2.2.0/css/material-design-iconic-font.min.css"/>
<link type="text/css" rel="stylesheet" href="${static}/plugin/radioCheckBox/src/pretty.min.css">
<link type="text/css" rel="stylesheet" href="${static}/plugin/drag/drag.css">
<link type="text/css" rel="stylesheet" href="${static}/plugin/calendar/simple-calendar.css">
<link type="text/css" rel="stylesheet" href="${static}/plugin/weather/leoweather.css">
<link rel="stylesheet" type="text/css" href="${static}/plugin/imgupload/css/cropper.min.css?r=0.6207188189209538">
<link rel="stylesheet" type="text/css" href="${static}/plugin/imgupload/css/mui.min.css?r=0.9207463414125734">
<link type="text/css" rel="stylesheet" href="${static}/plugin/jquery-plugin-circliful-master/css/jquery.circliful.css">

<!-- 自定义样式 -->
<link type="text/css" rel="stylesheet" href="${static}/css/fream.css"> <!-- 顶部和侧边 -->
<link type="text/css" rel="stylesheet" href="${static}/css/iconfont.css">
<link type="text/css" rel="stylesheet" href="${static}/css/main.css?r=0.4389791385058335">
<link type="text/css" rel="stylesheet" href="${static}/css/nav.css">
<link rel="stylesheet" type="text/css" href="${static}/css/processHelper.css?r=0.07160859914374484">
<link type="text/css" rel="stylesheet" href="${static}/css/dtable.css">
<link type="text/css" rel="stylesheet" href="${static}/page/back/firstpage/css/firstpage.css"><!-- 主页css -->
<link type="text/css" rel="stylesheet" href="${static}/css/btn.css">
<link type="text/css" rel="stylesheet" href="${static}/page/back/device/css/icon.css">

<link type="text/css" rel="stylesheet" href="${static}/page/back/customprint/file/cpTemple.css">
<link type="text/css" rel="stylesheet" href="${static}/js/utils/listRight/listRight.css">
<link type="text/css" rel="stylesheet" href="${static}/plugin/checkBox/dist/checkbox.min.css">
<link type="text/css" rel="stylesheet" href="${static}/page/back/maintainRecord/swiper/swiper.min.css">
<link type="text/css" rel="stylesheet" href="${static}/js/utils/slider/slider.css">
<link type="text/css" rel="stylesheet" href="${static}/plugin/select2-develop/dist/css/select2.min.css">
<link type="text/css" rel="stylesheet" href="${static}/plugin/wdScrollTab/css/TabPanel.css?V4.1-03082101">
<link type="text/css" rel="stylesheet" href="${static}/css/adminlte.min.css">
<link type="text/css" rel="stylesheet" href="${static}/css/common.css">




<script type="text/javascript" src="${static}/js/jquery.min.js"></script>
<script type="text/javascript" src="${static}/js/bootstrap.min.js"></script>
<script type="text/javascript" src="${static}/plugin/layer/layer.js"></script>
<script type="text/javascript" src="${static}/plugin/layui/layui.js"></script>
<script type="text/javascript" src="${static}/plugin/countdown/countdown.js"></script>
<script type="text/javascript" src="${static}/js/i-jquery.js?r=85145"></script>
<script type="text/javascript" src="${static}/js/main.js?v=123"></script>
<script type="text/javascript" src="${static}/js/imgClickBig.js"></script>
<script type="text/javascript" src="${static}/js/jquery.cookie.min.js?v=123456"></script>
<script type="text/javascript" src="${static}/plugin/datatable/media/js/jquery.dataTables.js"></script>
<script type="text/javascript" src="${static}/plugin/datatable/media/js/dataTables.bootstrap.js"></script>
<script type="text/javascript" src="${static}/js/jquery.timeago.js"></script>
<script type="text/javascript" src="${static}/js/jquery.form.js"></script>
<script type="text/javascript" src="${static}/plugin/bootstrap-select/js/bootstrap-select.js"></script>
<script type="text/javascript" src="${static}/plugin/drag/drag.js"></script>
<script type="text/javascript" src="${static}/plugin/calendar/simple-calendar.js"></script>
<script type="text/javascript" src="${static}/plugin/weather/jquery.leoweather.min.js"></script>
<script type="text/javascript" src="${static}/js/material-decomposition.js?r=123sdf"></script>
<script type="text/javascript" src="${static}/js/processHelper.js?r=324242"></script>
<script type="text/javascript" src="${static}/js/checkGroup.js?r=85145"></script>
<script type="text/javascript" src="${static}/js/iDistpicker.js?r=85145"></script>
<script type="text/javascript" src="${static}/plugin/bootstrap-datetimepicker-master/js/bootstrap-datetimepicker.js"></script>
<script type="text/javascript" src="${static}/plugin/bootstrap-datetimepicker-master/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
<script type="text/javascript" src="${static}/js/pmHelper.js"></script>
<script type="text/javascript" src="${static}/js/formUtil.js"></script>
<script type="text/javascript" src="${static}/js/layer-date-format.js"></script>
<script type="text/javascript" src="${static}/js/dateUtil.js"></script>
<script type="text/javascript" src="${static}/js/iUpload.js"></script>
<script type="text/javascript" src="${static}/plugin/eachrt4.1/echarts.js"></script>
<script type="text/javascript" src="${static}/plugin/jquery-plugin-circliful-master/js/jquery.circliful.js"></script>
<script type="text/javascript" src="${static}/plugin/utils/numberUtils.js"></script>
<script type="text/javascript" src="${static}/js/checkWindowClose.js"></script>
<script type="text/javascript" src="${static}/js/utils/common/fileUtils.js"></script>
<script type="text/javascript" src="${static}/js/utils/common/arrayUtils.js"></script>
<script type="text/javascript" src="${static}/js/utils/common/arrayUtils.js"></script>
<script type="text/javascript" src="${static}/js/utils/common/formUtil.js"></script>
<script type="text/javascript" src="${static}/js/utils/common/layer-tip.js"></script>

<script type="text/javascript" src="${static}/plugin/select2-develop/dist/js/select2.js"></script>
<script type="text/javascript" src="${static}/plugin/select2-develop/dist/js/pinyin.js"></script>

<!-- 生成二维码-->
<script type="text/javascript" src="${static}/plugin/qrcode/jquery.qrcode.js"></script>
<script type="text/javascript" src="${static}/plugin/qrcode/qrcode.js"></script>
<script type="text/javascript" src="${static}/plugin/qrcode/utf.js"></script>
<script type="text/javascript" src="${static}/plugin/JsBarcode-master/dist/JsBarcode.all.js"></script>

<!-- 树插件 -->
<link rel="stylesheet" href="${static}/plugin/ztree/zTreeStyle/zTreeStyle.css" />
<script type="text/javascript" src="${static}/plugin/ztree/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="${static}/js/PullDownTreeUtil2.js"></script>
<script src="${static}/plugin/jsPlumb/js/jsplumb.js"></script>
<script src="${static}/plugin/jsPlumb/flowchart-util.js"></script>

<script src="${static}/js/utils/listRight/listRightUtil.js"></script>
<script src="${static}/js/utils/checkUtils/checkUtils.js"></script>
<script src="${static}/page/back/patrolStatic/js/utils.js"></script>
<script src="${static}/js/utils/slider/slider.js"></script>
<script src="${static}/page/back/shuju/js/fullscreen.js"></script>
<script src="${static}/page/back/maintainRecord/swiper/swiper.min.js"></script>

<script  src="${static}/plugin/datatable/JSZip-2.5.0/jszip.min.js"></script>
<script  src="${static}/plugin/datatable/pdfmake-0.1.36/pdfmake.min.js"></script>
<script  src="${static}/plugin/datatable/Buttons-1.5.6/js/dataTables.buttons.js"></script>
<script  src="${static}/plugin/datatable/Buttons-1.5.6/js/buttons.flash.min.js"></script>
<script  src="${static}/plugin/datatable/Buttons-1.5.6/js/buttons.html5.js"></script>
<script  src="${static}/plugin/datatable/Buttons-1.5.6/js/buttons.print.js"></script>
<script  src="${static}/js/utils/table2excel/table2excel.js"></script>
<script  src="${static}/js/common.js"></script>

<link type="text/css" rel="stylesheet" href="${static}/page/back/maintenanceStaff/css/maintenanceStaff.css">
<link type="text/css" rel="stylesheet" href="${static}/page/back/device/css/icon.css">

<link type="text/css" rel="stylesheet" href="${static}/page/back/material/material.css">

<style>
    .oper-search{
        margin:5px 10px;
    }
    .page-content-s .dtable tbody tr td {
        text-overflow: inherit !important;
        white-space: inherit !important;
    }

    .icon-desc img{
        width: 16px;
        height: 16px;
        vertical-align: middle;
        margin-left : 20px;
        margin-right: 4px;
        margin-top: -3px;
    }

    .panel-selfclass{
        background-color: #DAF2FF;
        border-color: #ddd;
        padding: 10px 15px;
    }

    .dict-tree{
        min-width: 400px;
    }

    .panel-info {
        border-color: #bce8f1;
        min-height: 500px;
    }

    .ztree * {
        margin: 1px;
        font-size: 13px!important;
        font-family: Verdana, Arial, Helvetica, AppleGothic, sans-serif;
    }

    .ztree li {
        margin-top: 1px;
    }

    .content {
        padding: 0px 10px;
        overflow: hidden;
        width: 100%;
        height: 100%;
        background-color: #fff;
    }

    .page-content-s {
        margin: 10px 10px 0px;
        overflow: hidden;
        padding-bottom: 20px;
        background-color: #EEF1F6;;
    }

    /***隐藏导出按钮**/
    .dt-buttons {
        display: none;
    }

    /*!***隐藏页码**!
    div.dataTables_wrapper div.dataTables_paginate {
        margin: 0;
        white-space: nowrap;
        text-align: right;
        display: none;
    }
    !***隐藏第几页**!
    #redirectPage {
        position: relative;
        top: -13px;
        margin-left: 5px;
        display: none;
    }*/

    div#rMenu
    {
        position: absolute;
        visibility: hidden;
        top: 0;
        text-align: left;
        padding: 2px;
        background-color: #de6b6b;
        border-radius: 4px;
    }
    div#rMenu ul li
    {
        margin: 1px 0;
        padding: 0 5px;
        cursor: pointer;
        list-style: none outside none;
        color: #fff;
        font-size: 12px;
    }
</style>
<body  style="background-color: #EEF1F6;">

<div class="page-content-s">
    <!-- 顶部搜索框开始 -->
    <div class="oper-search">
        <form id="searchForm" class="form-inline" style="display:inline-block; margin-left:10px">
            <div class="form-group">
                <label>字典标签：</label>
                <input type="text" class="form-control search-cache" id="dictTextId1" name="dictText" placeholder="请输入字典标签" autocomplete="off">
            </div>
            <div class="form-group">
                <label>字典类型：</label>
                <input type="text" class="form-control search-cache" id="typeId1" name="type" placeholder="请输入字典类型" autocomplete="off">
            </div>
            <div class="form-group">
                <span class="btn glyphicon glyphicon-search btn-sm" id="searchBtn" onclick="searchBtn()">搜索</span>
                <span class="btn btn-sm glyphicon glyphicon-trash btn-del">删除</span>
                <span class="btn btn-sm glyphicon glyphicon-plus" onclick="addDictType(this);return false;">
                    新增字典类型</span>
                <span class="btn btn-sm glyphicon glyphicon-plus" onclick="addDictData(this);return false;">
                    新增字典数据</span>
            </div>
        </form>
        <!-- 导入文件 -->
    </div>

    <!-- 数据字典树 -->
    <div class="content">
        <div class="left-data dict-tree" style="min-width: 350px!important;">
            <div class="panel panel-info">
                <div class="panel-heading panel-selfclass materialCateTreeTitle">
                    <span>数据字典</span>
                    <div class="pull-right icon-desc">
                        <img src="${static}/imgs/tree/company.png"/>全部
                        <img src="${static}/imgs/tree/cate.png"/>字典类别
                        <img src="${static}/imgs/tree/material.png"/>字典数据
                    </div>
                </div>
                <div class="panel-body">
                    <div style="    max-height: 633px; overflow-y: auto;">
                        <div id="materialTree" style="width: 100%" class="ztree">
                            <!-- zTree -->
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="right-data" style="width: 20%!important;margin-top: 16px;">
             <table class="border">
                 <tr>
                     <td>上级标签</td>
                     <td>
                         <input type="text" class="form-control-gx" id="parentNodeId" readonly/>
                     </td>
                 </tr>
                 <tr>
                     <td>字典类型</td>
                     <td><input type="text" class="form-control-gx" id="dictTypeId2" readonly></td>
                 </tr>
                 <tr>
                     <td>字典类型名称</td>
                     <td>
                         <input type="text" class="form-control-gx" id="dictTypeNameId2" readonly/>
                     </td>
                 </tr>
                 <tr>
                     <td>字典标签</td>
                     <td>
                         <input type="text" class="form-control-gx" id="dictTextId2" readonly/>
                     </td>
                 </tr>
             </table>
        </div>
        <div class="right-data" style="max-width: 50%;">
            <div class="data-list" style="width:100%;">
                <table id="table" class="dtable Main_dtable">
                    <thead>
                    <tr>
                        <th style="width:20px;">
                            <div class="pretty success" style="margin: 0;">
                                <input type="checkbox" class="check-all" id="checkAllBtn">
                                <label><i class="mdi mdi-check"></i></label>
                            </div>
                        </th>
                        <td style="min-width:80px;">字典编号</td>
                        <td style="min-width:60px;">字典标签</td>
                        <td style="min-width:60px;">字典类型</td>
                        <!--<th style="min-width: 60px">状态</th>-->
                        <th style="min-width: 60px">创建时间</th>
                        <td style="min-width:50px;">操作</td>
                    </tr>
                    </thead>
                    <thead>
                    </thead>
                </table>
            </div>
        </div>
    </div>
</div>
<input type="text" id="clickId">

<!-- 右键树 -->
<div id="rMenu">
    <ul>
        <li id="m_del">删除</li>
    </ul>
</div>


</body>
</html>

<script>
    //注意：选项卡 依赖 element 模块，否则无法进行功能性操作
    var dataTable = $(".Main_dtable");
    /**********************************************************/
    var obj = '${trees}';
    var zNodes = JSON.parse(obj);
    var zTree, rMenu;
    $(function() {
        $.fn.zTree.init($("#materialTree"), setting, zNodes);
        zTree = $.fn.zTree.getZTreeObj("materialTree");
        rMenu = $("#rMenu");
        //var treeObj = $.fn.zTree.getZTreeObj("materialTree");
        //treeObj.expandAll(true);//展开所有
        /****datatable***************************************************/
        var noticetimeTypeMap = {0:"年",1:"月",2:"天",3:"小时"};
        sys.useSimpleRetrieveData();
        var staticPrefix = "${static}";
        var config = sys.DynamicDatabeConfig(staticPrefix,getSearchUrl(), [
            {
                data: null,
                render: function(data){
                    var html = '<div class="pretty success" style="margin: 0;">'+
                        '<input type="checkbox" data-id="'+data.id+'"> '+
                        '<label><i class="mdi mdi-check"></i></label>'+
                        '</div>';
                    return html;
                }
            },
            {
                data : 'dictValue',
            },
            {
                data : 'dictText',
            },
            {
                data : 'type',
            },
          /*  {
                data: 'delFlag',
                render:function(row, type, data, meta){
                    if(data.delFlag==0){
                        return "<span class='btn-block block-normal'>"+'未删除'+"</span>";
                    }else{
                        return "<span class='btn-block bg-red'>"+'已删除'+"</span>";
                    }

                }
            },*/
            {
                data : 'createTime',
            },
            {
                data : null,
                render : function(data) {return getOperHtml(data.id);}
            },

        ],true, {ordering:true});
        //禁止排序
        config.bSort=false;
        config.aLengthMenu = [15,25,50,100];
       // config.bLengthChange=false;隐藏每页显示多少条
      //  config.buttons = true;
        dataTable.dataTable(config).api().draw();
    })

    function getSearchPara() {
        var type = $("#typeId1").val().trim();
        var dictText = $("#dictTextId1").val().trim();
        var clickId = $("#clickId").val();
        var param = 'type='+type+'&dictText='+dictText+'&id='+clickId;
        return param;
    }

    function getSearchUrl(){
        var url = '/dict/ajaxDatatable?' + getSearchPara();
        url = encodeURI(url);
        return url;
    }

    function getOperHtml(id){
        var  html = '';
/*
        html += '<span class="btn btn-xs glyphicon glyphicon-pencil" onclick="edit(this,\''+id+'\');return false;">修改</span>&nbsp;';
*/
        html += '<span class="btn btn-xs glyphicon glyphicon-trash" onclick="deleteOne(\''+id+'\');return false;" >删除</span>';
        return html;
    }

    function searchBtn(){
        dataTable.api().ajax.url(getSearchUrl()).load(null, false).draw();
    }
    /******ZTREE*****************************************************************/
    var setting = {
        view: {
            selectedMulti: false, //是否允许多选
            showIcon: true,//设置 zTree 是否显示节点的图标。默认值：true
            showLine: true,//设置 zTree 是否显示节点之间的连线。默认值：true
            fontCss : {color:"#333"}
        },
        data: {
            simpleData: {
                enable: true
            }
        },
        callback: {
            //zTree节点的点击事件
            onClick: onClick,
            onRightClick:onRightClick
        }
    };

    /****右击事件   start*****************************************************/
    function onRightClick(event, treeId, treeNode) {
        if(treeNode.type=="1"){
            if (!treeNode && event.target.tagName.toLowerCase() != "button" && $(event.target).parents("a").length == 0) {
                zTree.cancelSelectedNode();
                showRMenu("root", event.clientX, event.clientY);
            } else if (treeNode && !treeNode.noR) {
                zTree.selectNode(treeNode);
                showRMenu("node", event.clientX, event.clientY);
            }
            $("#clickId").val(treeNode.id);
        }else{
            $("#rMenu").attr("visibility","hidden");
        }
    }
    function showRMenu(type, x, y) {
        $("#rMenu ul").show();
        if (type == "root") {
            $("#m_del").hide();
        } else {
            $("#m_del").show();
        }
        rMenu.css({ "top": y + "px", "left": x + "px", "visibility": "visible" });
        $("body").bind("mousedown", onBodyMouseDown);
    }
    function hideRMenu() {
        if (rMenu) rMenu.css({ "visibility": "hidden" });
        $("body").unbind("mousedown", onBodyMouseDown);
    }
    function onBodyMouseDown(event) {
        if (!(event.target.id == "rMenu" || $(event.target).parents("#rMenu").length > 0)) {
            rMenu.css({ "visibility": "hidden" });
        }
    }
    //隐藏右鍵
    function hideRMenu() {
        alert();
        if (rMenu) rMenu.css({ "visibility": "hidden" });
        $("body").unbind("mousedown", onBodyMouseDown);
    }
    /***右击删除事件***************************/
    $("#m_del").click(function () {
        sys.confirm("要删除的节点是父节点，如果删除将连同子节点一起删掉，确认删除吗？", confirmdel);
        function confirmdel() {
            $.ajax({
                url : "deleteDictype",
                type : "POST",
                datatype : "json",
                data : {
                    "id" : $("#clickId").val(),
                },
                success : function(data, stats) {
                    if (data.success) {
                        js.showMessage(data.data,"","success",1500)
                        reloadTree();
                    } else {
                        js.showMessage("删除失败","","error",1500)
                    }
                },
                error : function(data) {
                    js.showMessage("请求异常","","error",1500)
                }
            });
        }
    })
    /****右击事件   end*****************************************************/

    //点击某个节点 然后将该节点的名称赋值值文本框
    function onClick(e, treeId, treeNode) {
        //var zTree = $.fn.zTree.getZTreeObj("materialTree");
        //获得选中的节点
        var nodes = zTree.getSelectedNodes(), v = "";
        //根据id排序
        nodes.sort(function compare(a, b) { return a.id - b.id; });
        for (var i = 0, l = nodes.length; i < l; i++) {
            if(i!==0){
                v +=","+nodes[i].name ;
            }
            v +=nodes[i].name;
        }
        if (nodes.length > 0) {
            var parentNode = nodes[0].getParentNode();
            if(null!=parentNode && ""!=parentNode){
                //获取父节点的节点名称
                var parentNodeName=parentNode.name;
                $("#parentNodeId").val(parentNodeName);
                showCenterData(treeNode.id);
            }
        }
        //表格加载用
        $("#clickId").val(treeNode.id);
        $("#dictTextId2").val(treeNode.name);
        //重构表格
        dataTable.api().ajax.url(getSearchUrl()).load(null, false).draw();
    }
    /****根据选择树数据，显示中间表格数据********************/
    function showCenterData(val) {
        $.ajax({
            url : "getCenterDatas",
            type : "POST",
            datatype : "json",
            data : {
                "id":val
            },
            success : function(res, stats) {
                if (res.success) {
                    $("#dictTextId2").val(res.data.data.dictText);//字典数据名
                    $("#dictTypeId2").val(res.data.data.type);//字典类型
                    $("#dictTypeNameId2").val(res.data.data.dictTypeText);//字典标签值
                } else {
                    js.showMessage(res.data.message,"","error",1500)
                }
            },
            error : function(res) {
                js.showMessage("请求异常","","error",1500)
            }
        });
    }
    /****新增字典类型****************************/
    function addDictType(obj) {
        var $this = $(obj);
        var url = "/dict/addDictType";
        js.addTabPage($this,'新增字典类型',url,true,true);
    }
    /****新增字典数据****************************/
    function addDictData(obj) {
        var $this = $(obj);
        var url = "/dict/addDictData";
        js.addTabPage($this,'新增字典数据',url,true,true);
    }
    /**新增完成关掉页签，刷新主页****************/
    function reload(){
        //重新获取znodes、刷新表格
        reloadTree();
    }
    /**新增结束，重新获取tree数据刷新*********************************/
    function reloadTree() {
        $.ajax({
            url : "treeReload",
            type : "POST",
            datatype : "json",
            data : {

            },
            success : function(res, stats) {
                if (res.success) {
                    var dataVal = res.data;
                    var treeData = JSON.parse(dataVal);
                    $.fn.zTree.init($("#materialTree"), setting, treeData);
                    dataTable.dataTable().api().draw();
                    $("#parentNodeId").val("");
                    $("#dictTextId2").val("");//字典数据名
                    $("#dictTypeId2").val("");//字典类型
                    $("#dictTypeNameId2").val("");//字典标签值
                } else {
                    js.showMessage("获取树结构失败","","error",1500)
                }
            },
            error : function(data) {
                js.showMessage("请求异常","","error",1500)
            }
        });
    }
    /**单条删除**********************************/
    function deleteOne(id) {
        sys.confirm("确定删除该数据吗？", confirmdel);
        function confirmdel() {
            $.ajax({
                url : "deleteDcitData",
                type : "POST",
                datatype : "json",
                data : {
                    "id" : id,
                },
                success : function(data, stats) {
                    if (data.success) {
                        js.showMessage(data.data,"","success",1500)
                        reloadTree();
                    } else {
                        js.showMessage("删除失败","","error",1500)
                    }
                },
                error : function(data) {
                    js.showMessage("请求异常","","error",1500)
                }
            });
        }
    }
    /***批量删除***********************************************/
    function delBatch(ids) {
        sys.confirm("确定删除选中数据吗？", confirmdel);
        function confirmdel() {
            $.ajax({
                url : "delBatch",
                type : "POST",
                datatype : "json",
                data : {
                    "ids" : ids,
                },
                success : function(data, stats) {
                    if (data.success) {
                        $(".check-all").attr("checked", false);
                        js.showMessage(data.data,"","success",1500)
                        reloadTree();
                    } else {
                        js.showMessage("删除失败","","error",1500)
                    }
                },
                error : function(data) {
                    js.showMessage("删除失败","","error",1500)
                }
            });
        }
    }
    /*多条删除*/
    $(document.body).find(".btn-del").on("click", function(){
        var chks = $(document.body).find("[type='checkbox']:not(.check-all):checked");

        if(chks && chks.length){
            var ids = "";
            for(var i = 0; i < chks.length; i++){
                if(ids.length > 0){
                    ids += ",";
                }
                ids += chks.eq(i).data("id");
            }
            delBatch(ids);
        }else {
            //sys.topmsg("请勾选要删除的数据");
            js.showMessage("请勾选要删除的数据！",null,"warning",1500);
            return;
        }
    });
    /*全选*/
    $("#table").on("click", "[type='checkbox']", function(e){
        e.stopPropagation();
        var jqCheck = $(this);
        if(jqCheck.hasClass("check-all")){
            $(document.body).find("[type='checkbox']:not(.check-all)").each(function(){
                this.checked = jqCheck[0].checked;
            })
        }else {
            var allChecked = true;
            $(document.body).find("[type='checkbox']:not(.check-all)").each(function(){
                if(!this.checked){
                    allChecked = false;
                }
            });
            $(document.body).find(".check-all")[0].checked = allChecked;
        }
    });
</script>
